package com.argrace.smart.adapter;

import android.content.Context;
import android.view.View;

import com.argrace.smart.R;
import com.argrace.smart.model.LocalDb_RoomNameTable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by argrace_dev_1 on 2018/3/8.
 */

public class RoomAdapter extends BaseQuickAdapter<LocalDb_RoomNameTable, BaseViewHolder> {
    private Context context;

    public RoomAdapter(List<LocalDb_RoomNameTable> data, Context context) {
        super(R.layout.item_room, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, final LocalDb_RoomNameTable item, final int position) {
        baseViewHolder.setText(R.id.item_room_text, item.getRoomName());
        baseViewHolder.setOnClickListener(R.id.item_room_img, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.click(item, position);
            }
        });
    }

    private OnAdapterItemClickListener listener;

    public interface OnAdapterItemClickListener {
        void click(LocalDb_RoomNameTable bean, int position);
    }

    public void setListeners(OnAdapterItemClickListener l) {
        this.listener = l;
    }
}

